//
// Created by root on 2/18/18.
//

#ifndef FUNNY_TRANSLATOR_COMPONENT_H
#define FUNNY_TRANSLATOR_COMPONENT_H

#include <stdio.h>
#include "../fa/automata.h"

#define MODULE_TYPE_FUNCTION   1
#define MODULE_TYPE_CLASS      2
#define MODULE_TYPE_PROCEDURE  3

typedef struct _ModuleMeta {
    int moduleType;
    String moduleName;
    String modulePath;
} ModuleMeta;

typedef struct _FunctionMeta {
    String moduleName;
    Queue *functions;
} FunctionMeta;

typedef struct _ClassMeta {
    String moduleName;
    String className;
    Queue *properties;
    Queue *methods;
} ClassMeta;

typedef struct _MethodMeta {
    String methodName;
    Queue* methodArgs;
    Statement* methodDef;
} MethodMeta;

typedef struct _GenericFunctionMeta {
    String moduleName;
} GenericFunctionMeta;

typedef struct _Component {
    String name;
    // Queue *requireComponents;
    Queue *functions;
    Queue *classes;
    Queue *genericFunctions;
    Queue *executables;
    //...
} Component;

void cache_component_path(String component);
//void build_component(Component *component, FILE *metaFile);

void *build_component(FILE *metaFile);

void build_meta_data(Queue *queue);
Queue *parse_functions_meta_data(FILE *metaFile);
Queue *parse_classes_meta_data(FILE *metaFile);

void do_with_functions(Queue *functions);
void do_with_classes(Queue *classTrees);
void do_with_class_module(TreeNode *node);
void merge_tree(Tree *tree);

#endif //FUNNY_TRANSLATOR_COMPONENT_H
